#pragma once
#include<iostream>
using namespace std;

template<class T>
class Myarray
{
public:
	Myarray(int capacity) {
		this->mcapacity = capacity;
		this->msize = 0;
		this->p = new T[this->mcapacity];

	}	
	Myarray(const Myarray& arr) {
		this->mcapacity = arr.mcapacity;
		this->msize = arr.msize;
		this->p = new T[arr.mcapacity];
		for (int i = 0; i < this->msize; i++) {
			this->p[i] = arr.p[i];
		}

	}
	Myarray& operator=(const Myarray& arr)
	{
		if (this->p != NULL) {
			delete[]this->p;
			this->p = NULL;
			this->mcapacity = 0;
			this->msize = 0;

		}
		this->mcapacity = arr.mcapacity;
		this->msize = arr.msize;
		this->p = new T[arr.mcapacity];
		for (int i = 0; i < this.msize; i++) {
			this->p[i] = arr.p[i];
		}
		return *this;

	}

	void pushback(const T& val) {

		if (this->mcapacity == this->msize) {
			return;
		}
		this->p[this->msize] = val;
		this->msize++;
	}
	void delback() {

		if (0== this->msize)
		{
			return;
		}
		
		this->msize--;
	}



	


T& operator[](int index) {
	return this->p[index];
}

int getmcapacity() {
	return this->mcapacity;

}
int getmsize() {
	return this->msize;

}

	~Myarray() {
		if (this->p != NULL) {
			delete[]this->p;
			this->p=NULL;
		}
	}
private:
	T* p;
	int msize;
	int mcapacity;

};